package com.usian.controller;

import com.usian.feign.WemediaFeign;
import com.usian.model.admin.dtos.NewsAuthDto;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.pojos.WmNews;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/api/v1/news_auth")
@RestController
public class AdMediaController {

    @Autowired
    private WemediaFeign wemediaFeign;

    @PostMapping("/list")
    public PageResponseResult list(@RequestBody NewsAuthDto dto){
        return wemediaFeign.findListRengong(dto);
    }

    @GetMapping("/one/{id}")
    public ResponseResult findDetail(@PathVariable("id")Integer id){
        WmNews wmNews = wemediaFeign.findDetail(id);
        return ResponseResult.okResult(wmNews);
    }

    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto){
       return wemediaFeign.auth(dto,1) ;
    }

    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        return wemediaFeign.auth(dto,0) ;
    }
}
